module('sqlescape', package.seeall)

function MySQLEscape(Value)
    return Value:gsub('["\'\\%z]', {
        ['"']  = '\\"', ['\0'] = '\\0',
        ["'"]  = "\\'", ['\\'] = '\\\\',
    })
end

function SingleQuoteEscape(Value)
    return Value:gsub("'", "''")
end

function PostgresEscape(Value)
    return Value:gsub("['\\]", {["'"] = "''", ["\\"] = "\\\\"})
end

function AddQuotes(Value)
    return "'" .. Value .. "'"
end